﻿//<TunynetCopyright>
//--------------------------------------------------------------
//<copyright>青岛拓宇网络科技有限公司 2005-2008</copyright>
//<version>V0.5</verion>
//<createdate>2008-3-3</createdate>
//<author>mazq</author>
//<email>mazq@tunynet.com</email>
//<log date="2008-3-3">创建</log>
//--------------------------------------------------------------
//</TunynetCopyright>

using System;
using System.Collections.Generic;
using System.Text;
using System.Workflow.ComponentModel;
using System.Workflow.Activities;
using System.ComponentModel;
using System.Workflow.Runtime;
using ChinaCustoms.Qingdao.Workflow.Supports;
using System.Drawing.Design;

namespace ChinaCustoms.Qingdao.Workflow.Activities
{
    /// <summary>
    /// 海关工作流活动抽象基类
    /// </summary>
    public abstract class ChinaCustomsBaseActivity : Activity
    {
        /// <summary>
        /// 执行活动
        /// </summary>
        /// <param name="context">活动执行上下文</param>
        /// <returns>活动执行状态</returns>
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext context)
        {
            if (CurrentStatus == ActivityStatus.Creating)
            {
                //在数据库创建活动实例
                currentStatus = ActivityStatus.Executing;
            }

            return ActivityExecutionStatus.Executing;
        }


        private ActivityStatus currentStatus = ActivityStatus.Creating;

        /// <summary>
        /// 活动当前状态
        /// </summary>
        /// <remarks>
        /// 设计时排除该属性
        /// </remarks>
        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public ActivityStatus CurrentStatus
        {
            get { return currentStatus; }
        }

        private Guid? activityGuid = null;

        /// <summary>
        /// 活动ID
        /// </summary>
        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Guid ActivityGuid
        {
            get
            {
                if (!activityGuid.HasValue)
                    activityGuid = Guid.NewGuid();

                return activityGuid.Value;
            }
        }

        /// <summary>
        /// 活动级别(必须填写,并且要唯一,活动之间要递加)
        /// </summary>
        public abstract int ActivityLevel
        {
            get;
            set;
        }

        /// <summary>
        /// 活动编码(必须填写,并且要唯一,只允许在设计期间修改)
        /// </summary>
        public abstract string CodeName
        {
            get;
            set;
        }

        ///// <summary>
        ///// 是否允许在运行时指定执行人
        ///// </summary>
        //public abstract bool AllowRedesignateExecutor
        //{
        //    get;
        //    set;
        //}

        ///// <summary>
        ///// 是否允许审批意见
        ///// </summary>
        //public abstract bool AllowPostil
        //{
        //    get;
        //    set;
        //}

        ///// <summary>
        ///// 可跳转到的活动编码
        ///// </summary>
        //public abstract string ActivityCodeNamesForJump
        //{
        //    get;
        //    set;
        //}

        ///// <summary>
        ///// 是否允许回退
        ///// </summary>
        //public abstract bool AllowBack
        //{
        //    get;
        //    set;
        //}

        ///// <summary>
        ///// 活动对应的直接部门ID
        ///// </summary>
        //public abstract string RequiredDepartmentIDs
        //{
        //    get;
        //    set;
        //}


        ///// <summary>
        ///// 活动对应的相对部门
        ///// </summary>
        //public abstract RelativeDepartmentLevel RequiredRelativeDepartment
        //{
        //    get;
        //    set;
        //}

        ///// <summary>
        ///// 需要操作该活动的角色列表,多个角色用逗号分隔
        ///// </summary>
        //public abstract string RequiredRoles
        //{
        //    get;
        //    set;
        //}

        ///// <summary>
        ///// 需要操作该活动的用户组列表,多个用户组用逗号分隔
        ///// </summary>
        //public abstract string RequiredUserGroups
        //{
        //    get;
        //    set;
        //}


        ///// <summary>
        ///// 需要操作该活动的用户名列表,多个用户名用逗号分隔
        ///// </summary>
        //public abstract string RequiredUserNames
        //{
        //    get;
        //    set;
        //}

        /// <summary>
        /// 处理及查看工作项的URL
        /// </summary>
        public abstract string UrlOfWorkItem
        {
            get;
            set;
        }

    }
}
